<%@ page language="java" contentType="text/html; charset=UTF-8"
  pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="d" uri="/WEB-INF/resource.tld"%>
<!DOCTYPE html>
<html lang="zh-CN">

<head>

<%@ include file="/WEB-INF/include/meta.jsp"%>
<%@ include file="/WEB-INF/include/css.jsp"%>

</head>
<!-- end header -->
<body>
  <div class="page-group">
    <div class="page page-current">
      <header class="bar bar-nav fs-header-small">
        <a href="javascript:history.back(-1)" class="icon icon-left pull-left"></a>
        <h1 class="title">卡券详情</h1>
      </header>
      
      <div class="content">
        <c:choose>
          <c:when test="${empty coupon}">
              <p class="text-center" style="margin-top: 5rem; color: #999;">不存在的优惠券</p>
          </c:when>
          <c:otherwise>
            <div class="list-block media-list payment-list" style="margin-bottom: .5rem;">
              <ul>
                <li>
                  <div class="item-content order-info">
                    <div class="item-inner">
                      <div class="item-title" style="white-space: normal;">${coupon.templateName}</div>
                      <div class="item-text">
                        <p>抵扣类型：${coupon.template.discountType.description}</p>
                        <c:if test="${coupon.template.discountType.fixedAmount}">
                          <p>抵扣金额：￥${coupon.amount/100}</p>
                          <p>最低消费：￥${coupon.template.minAmount/100}</p>
                        </c:if>
                        <p>有效时间：<fmt:formatDate value="${coupon.effectiveStartDate}" pattern="yyyy-MM-dd"/>&nbsp;至&nbsp;<fmt:formatDate value="${coupon.effectiveEndDate}" pattern="yyyy-MM-dd"/></p>
                        <c:if test="${coupon.template.discountType.percent && not empty coupon.originalUserId}">
                          <p>来&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;源：${originalUserName}赠送</p>
                        </c:if>
                      </div>
                    </div>
                  </div>
                </li>
              </ul>
            </div>
            
            <c:if test="${coupon.template.discountType.percent and empty coupon.originalUserId}">
              <div class="content-block" style="margin: 0px;">
                <p><a href="#" class="button button-big button-success button-fill" style="background-color: #FDDD32; color: #000;">转赠</a></p>
              </div>
            </c:if>
          </c:otherwise>
        </c:choose>
      </div>

    </div>
  </div>

  <%@ include file="/WEB-INF/include/script.jsp"%>
  <d:resource type="script" root="${ctx.resource}/build"
    src="js/page/profile/profile-coupon-view.js" />
  <script type="text/javascript">
    require([ 'page/profile/profile-coupon-view' ], function(page) {
      var data = {
        couponId : '${coupon.id}',
      }
      page.init(data)
    })
  </script>

</body>
</html>